#include "gamma-manager-plugin.h"

PluginInterface *GammaManagerPlugin::m_Instance = nullptr;
ManagerInterface *GammaManagerPlugin::m_pManager = nullptr;


GammaManagerPlugin::GammaManagerPlugin()
{
    USD_LOG(LOG_DEBUG,"initializing");
    if (!UsdBaseClass::isWayland() && nullptr == m_pManager) {
        m_pManager = GammaManagerWayland::GammaManagerWaylandNew();
    } else if(nullptr == m_pManager) {
        m_pManager = GammaManager::GammaManagerNew();
    }
}

GammaManagerPlugin::~GammaManagerPlugin()
{
    if (m_pManager != nullptr) {
        delete m_pManager;
    }
}

void GammaManagerPlugin::activate()
{
    m_pManager->Start();
}

void GammaManagerPlugin::deactivate()
{
    m_pManager->Stop();
}

PluginInterface *GammaManagerPlugin::getInstance()
{
    if (nullptr == m_Instance){
        m_Instance = new GammaManagerPlugin();
    }
    return m_Instance;
}


PluginInterface *createSettingsPlugin()
{
    return GammaManagerPlugin::getInstance();
}
